﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefEquipment" :model="stateEquipment.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipName_FormItem" prop="Entity.EquipName" :label="$t('message.autotrans._Model_Equipment_EquipName')">
            <el-input v-model="stateEquipment.vmModel.Entity.EquipName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipCode_FormItem" prop="Entity.EquipCode" :label="$t('message.autotrans._Model_Equipment_EquipCode')">
            <el-input v-model="stateEquipment.vmModel.Entity.EquipCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EquipType_FormItem" prop="Entity.EquipType" :label="$t('message.autotrans._Model_Equipment_EquipType')">
            <el-select v-model="stateEquipment.vmModel.Entity.EquipType" disabled clearable>
               <el-option key="Equipment" value="Equipment" :label="$t('message.autotrans._Enum_EquipTypeEnum_Equipment')"></el-option>
               <el-option key="Tooling" value="Tooling" :label="$t('message.autotrans._Enum_EquipTypeEnum_Tooling')"></el-option>
               <el-option key="Mould" value="Mould" :label="$t('message.autotrans._Enum_EquipTypeEnum_Mould')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_SpotType_FormItem" prop="Entity.SpotType" :label="$t('message.autotrans._Model_Equipment_SpotType')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Equipment_SpotType')}), trigger: 'blur' }]" >
            <el-select v-model="stateEquipment.vmModel.Entity.SpotType" disabled clearable>
               <el-option key="Barcode" value="Barcode" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_Barcode')"></el-option>
               <el-option key="Itemized" value="Itemized" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_Itemized')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_EquipSpotCheckEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_DriverType_FormItem" prop="Entity.DriverType" :label="$t('message.autotrans._Model_Equipment_DriverType')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Equipment_DriverType')}), trigger: 'blur' }]" >
            <el-select v-model="stateEquipment.vmModel.Entity.DriverType" disabled clearable>
               <el-option key="OpcUa" value="OpcUa" :label="$t('message.autotrans._Enum_DriverTypeEnum_OpcUa')"></el-option>
               <el-option key="None" value="None" :label="$t('message.autotrans._Enum_DriverTypeEnum_None')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IpAddress_FormItem" prop="Entity.IpAddress" :label="$t('message.autotrans._Model_Equipment_IpAddress')">
            <el-input v-model="stateEquipment.vmModel.Entity.IpAddress" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Port_FormItem" prop="Entity.Port" :label="$t('message.autotrans._Model_Equipment_Port')">
            <el-input v-model="stateEquipment.vmModel.Entity.Port" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Actvie_FormItem" prop="Entity.Actvie" :label="$t('message.autotrans._Model_Equipment_Actvie')">
            <el-input v-model="stateEquipment.vmModel.Entity.Actvie" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Manufactor_FormItem" prop="Entity.Manufactor" :label="$t('message.autotrans._Model_Equipment_Manufactor')">
            <el-input v-model="stateEquipment.vmModel.Entity.Manufactor" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Aux_1_FormItem" prop="Entity.Aux_1" :label="$t('message.autotrans._Model_Equipment_Aux_1')">
            <el-input v-model="stateEquipment.vmModel.Entity.Aux_1" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Aux_2_FormItem" prop="Entity.Aux_2" :label="$t('message.autotrans._Model_Equipment_Aux_2')">
            <el-input v-model="stateEquipment.vmModel.Entity.Aux_2" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_Equipment_CreateTime')">
            <el-input v-model="stateEquipment.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_Equipment_UpdateTime')">
            <el-input v-model="stateEquipment.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_Equipment_CreateBy')">
            <el-input v-model="stateEquipment.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_Equipment_UpdateBy')">
            <el-input v-model="stateEquipment.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_Equipment_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Equipment_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipment.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseEquipment"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentApi } from '/@/api/equipmentmanagement/equipment';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipment = ref();
const stateEquipment = reactive({
    vmModel: {
	  Entity:{
        EquipName: '',
        EquipCode: '',
        EquipType: undefined,
        SpotType: undefined,
        DriverType: undefined,
        IpAddress: '',
        Port: '',
        Actvie: undefined,
        Manufactor: '',
        Aux_1: '',
        Aux_2: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
});

// 取消
const onCloseEquipment = () => {
    closeDialog();
};

// 提交
const onSubmitEquipment = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefEquipment.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipmentApi().edit(stateEquipment.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateEquipment.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipment.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	equipmentApi().get(stateEquipment.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateEquipment.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

